@echo off
echo ==========================================
echo        重新实现功能测试脚本
echo ==========================================
echo.

echo 提示：请先重启所有服务
echo   - Eureka Server (18000)
echo   - Provider Service (11000, 11001)  
echo   - Gateway Service (9000)
echo.
echo 按任意键开始测试...
pause >nul
echo.

echo [步骤1] 验证Provider服务直接访问
echo -----------------------------------------
echo 🔍 Provider 11000:
curl -s http://localhost:11000/user/getUserById/1
echo.
echo.

echo 🔍 Provider 11001:
curl -s http://localhost:11001/user/getUserById/1
echo.
echo.

echo [步骤2] 验证Gateway服务状态
echo -----------------------------------------
echo 🔍 Gateway Ping:
curl -s http://localhost:9000/test/ping
echo.
echo.

echo [步骤3] 测试认证功能
echo -----------------------------------------
echo 🔐 无Token访问(应该返回401):
curl -s -w "状态码: %%{http_code}" http://localhost:9000/test/auth-required
echo.
echo.

echo ✅ 有效Token访问(应该返回200):
curl -s -w "状态码: %%{http_code}" -H "Authorization: Bearer mytoken" http://localhost:9000/test/auth-required
echo.
echo.

echo [步骤4] 测试Provider路由负载均衡
echo -----------------------------------------
echo 🔀 通过Gateway访问Provider(有Token):
for /L %%i in (1,1,3) do (
    echo 请求 %%i:
    curl -s -H "Authorization: Bearer mytoken" http://localhost:9000/provider/user/getUserById/1
    echo.
)
echo.

echo [步骤5] 测试负载均衡演示接口
echo -----------------------------------------
echo 🎯 lb-demo路由测试:
for /L %%i in (1,1,5) do (
    echo lb-demo请求 %%i:
    curl -s http://localhost:9000/lb-demo/user/instance-info
    echo.
)
echo.

echo [步骤6] 查看服务发现信息
echo -----------------------------------------
echo 📊 服务注册情况:
curl -s http://localhost:9000/monitor/services
echo.
echo.

echo ==========================================
echo           测试完成！
echo ==========================================
echo.
echo 期望结果：
echo 1. 步骤1和2应该返回正常数据
echo 2. 步骤3无Token应该返回401，有Token应该返回200
echo 3. 步骤4和5应该显示11000和11001端口轮换
echo 4. 步骤6应该显示服务注册信息
echo.

pause 